package com.molichuxing.job;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import com.molichuxing.service.OrderJobService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.IJobHandler;
import com.xxl.job.core.handler.annotation.JobHandler;

@JobHandler(value = "orderOverdueHandler")
@Component
public class OrderOverdueHandler extends IJobHandler {
	private static final Logger logger = LoggerFactory.getLogger(OrderOverdueHandler.class);

	@Resource
	private OrderJobService orderJobService;

	public OrderOverdueHandler() {
        super();
    }

	@Override
	public void init() {
		super.init();
	}

	@Override
	public void destroy() {
		super.destroy();
	}

	@Override
	public ReturnT<String> execute(String param) throws Exception {
		ReturnT<String> returnT = ReturnT.SUCCESS;
		logger.info("==============订单逾期统计定时任务start================");
		boolean result = orderJobService.orderOverdueAllReminderToServicer();
		if (!result) {
			returnT = ReturnT.FAIL;
		}
		logger.info("==============订单逾期统计定时任务end================");
		returnT.setContent("订单逾期统计定时任务结果result：" + result);
		return returnT;
	}

//	@org.junit.Test
//	public void test() throws Exception {
//		ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");
//
//		OrderJobService orderJobService = (OrderJobService) context.getBean("orderJobService");
//		orderJobService.orderOverdueReminderToUser();
//	}

}
